package hotgammon.domain;

public class DiceAlphamon implements Dice {
    
    Game game;
    int[] diceValues = null;
    int[] diceValuesLeft = null;
    int numThrown;
    
    public void setGame(Game game) {
        this.game=game;
    }
    
    public int[] getDiceValues() {
        return this.diceValues;
    }
    
    public int[] thrown() {
        switch (this.numThrown+1) {
            default:
            case 1:
            case 2:
                return this.setDice(1,2);
            case 3:
            case 4:
                return this.setDice(3,4);
            case 5:
            case 6:
                return this.setDice(5,6);
        }
    }
    
    public int[] setDice(int n1, int n2) {
        numThrown++;
        diceValues = new int[] {n1, n2};
        return diceValuesLeft = new int[] {n1, n2};
    }
    
    public int getNumberOfMovesLeft() {
        int res = 0;
        if (this.diceValues!=null) {
            for (int n : this.diceValues) {
                if (n!=0) res++;
            }
        }
        return res;
    }
    
    public int[] getValuesLeft() {
        return diceValues;
    }
    
    public void setDiceValues(int[] diceValues) {
        this.diceValues = diceValues;
    }
    
    public void setDiceValuesLeft(int[] diceValuesLeft) {
        this.diceValuesLeft = diceValuesLeft;
    }    
    
    public int getNumThrown() {
        return this.numThrown;
    }
    
    public void setNumThrown(int numThrown) {
        this.numThrown=numThrown;
    }
    
    public int getDiceSum(int[] diceValues) {
        int sum = 0;
        for (int n : diceValues) {
            sum+=n;
        }
        return sum;
    }
    
    public void setAutoIncrement(boolean value) {
    }
}
